package logic

import (
	"context"
	"doctor-medicine-system/api/internal/svc"
	"doctor-medicine-system/api/internal/types"
	"doctor-medicine-system/doctorrpc/doctorrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DoctorDataAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDoctorDataAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DoctorDataAddLogic {
	return &DoctorDataAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DoctorDataAddLogic) DoctorDataAdd(req *types.DoctorDataAddRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	add, err := l.svcCtx.DoctorRpc.DoctorDataAdd(l.ctx, &doctorrpc.DoctorDataAddRequest{
		Name:    req.Name,
		Size:    req.Size,
		Person:  req.Person,
		Types:   req.Types,
		Number:  req.Number,
		Content: req.Content,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "添加成功",
		Code:    200,
		Data:    add,
	}, nil
}
